package chan.project.smartlaweveryman.strategy;

import chan.project.smartlaweveryman.strategy.register.CommonRegisterStrategy;
import chan.project.smartlaweveryman.strategy.register.LawyerRegisterStrategy;
import chan.project.smartlaweveryman.strategy.register.RegisterStrategy;
import chan.project.smartlawmodel.dto.user.UserInfoRegisterRequest;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;

@Component
public class RegisterManager {

    @Resource
    private CommonRegisterStrategy commonRegisterStrategy;

    @Resource
    private LawyerRegisterStrategy lawyerRegisterStrategy;

    public Long commonRegister(UserInfoRegisterRequest userInfoRegisterRequest){
        commonRegisterStrategy.hasRoleOrRegister(userInfoRegisterRequest);
        Long userId = commonRegisterStrategy.saveUser(userInfoRegisterRequest);
        return commonRegisterStrategy.saveRole(userId);
    }

    public Long lawyerRegister(UserInfoRegisterRequest userInfoRegisterRequest){
        lawyerRegisterStrategy.hasRoleOrRegister(userInfoRegisterRequest);
        Long userId = lawyerRegisterStrategy.saveUser(userInfoRegisterRequest);
        return lawyerRegisterStrategy.saveRole(userId);
    }

}
